$(function(){
  const layer = layui.layer
  // 1.登录表单提交事件
  $('#formLogin').on('submit',function(e){
    e.preventDefault()
    const data = $(this).serialize()

    $.ajax({
      method:'POST',
      url:'http://124.223.14.236:3001/api/user/login',
      data,
      success:function(res){
        if(!res.success) return layer.msg('登录失败')
        layer.msg('登录成功')
        localStorage.setItem('token',res.data.token)
      }
    })
  })
})